﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TDAPIOLELib;

namespace QCCure.Core
{
    [Serializable]
    public class QCProject
    {
        private string domain;
        private string project;

        public QCProject(string domain, string project)
        {
            this.domain = domain;
            this.project = project;
        }

        public QCProject(IProjectDescriptor project)
        {
            this.domain = project.DomainName;
            this.project = project.Name;
        }

        public string Domain { get { return domain; } }
        public string Project { get { return project; } }

        // override object.Equals
        public override bool Equals(object obj)
        {
           
            if (obj == null || GetType() != obj.GetType())
            {
                return false;
            }

            QCProject other = obj as QCProject;

            return StringComparer.CurrentCulture.Equals(domain, other.domain) &&
                   StringComparer.CurrentCulture.Equals(project, other.project);
        }

        // override object.GetHashCode
        public override int GetHashCode()
        {
            int domainHashCode = domain != null ? domain.GetHashCode() : 0;
            int projectHashCode = project != null ? project.GetHashCode() : 0;
            return projectHashCode ^ ((int)domainHashCode >> 32);
        }

        public override string ToString()
        {
            return domain + " - " + project;
        }

    }
}
